<html>
<head>
<title>vue.config.js</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.s0 { color: #cc7832;}
.s1 { color: #a9b7c6;}
.s2 { color: #6a8759;}
.s3 { color: #808080;}
.s4 { color: #6897bb;}
</style>
</head>
<body bgcolor="#2b2b2b">
<table CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#606060" >
<tr><td><center>
<font face="Arial, Helvetica" color="#000000">
vue.config.js</font>
</center></td></tr></table>
<pre><span class="s0">let </span><span class="s1">proxyObj = {}</span><span class="s0">;</span>

<span class="s1">proxyObj[</span><span class="s2">'/'</span><span class="s1">] = {</span>
    <span class="s3">//websocket</span>
    <span class="s1">ws:</span><span class="s0">false,</span>
    <span class="s3">//目标地址</span>
    <span class="s1">target:</span><span class="s2">'http://localhost:5999'</span><span class="s0">,</span>
    <span class="s3">//发送请求头host会被设置成target</span>
    <span class="s1">changeOrigin:</span><span class="s0">true,</span>
    <span class="s3">//不重写请求地址</span>
    <span class="s1">pathRewrite:{</span>
        <span class="s2">'^/'</span><span class="s1">:</span><span class="s2">'/'</span>
    <span class="s1">}</span>
<span class="s1">}</span>

<span class="s1">proxyObj[</span><span class="s2">'/ws'</span><span class="s1">] = {</span>
    <span class="s1">ws:</span><span class="s0">true,</span>
    <span class="s1">target:</span><span class="s2">'ws://localhost:5999'</span><span class="s0">,</span>
<span class="s1">}</span>

<span class="s1">module.exports = {</span>
    <span class="s1">devServer:{</span>
        <span class="s1">host:</span><span class="s2">'localhost'</span><span class="s0">,</span>
        <span class="s1">port:</span><span class="s4">8080</span><span class="s0">,</span>
        <span class="s1">proxy:proxyObj</span>
    <span class="s1">}</span>
<span class="s1">}</span></pre>
</body>
</html>